﻿var strpicpath = '';
YXQ.UploadCenter = {
    FileUploadCenter: function (optype) {
        $("#uploadify").uploadify({
            uploader: '../Infrastructure/uploadify.swf?var=' + (new Date()).getTime(),
            script: '../Handler/FileUploadHandler.ashx?OpType=' + optype,
            cancelImg: '../Infrastructure/cancel.png',
            queueID: 'fileQueue',
            auto: false,
            multi: false,
            scriptData: { 'HfId': $("[DataField='hfId']").val() },
            onComplete: function (event, queueId, fileObj, response, data) {
                strpicpath = "";
                strpicpath = response.toString();
            },
            onAllComplete: function (data) {
            
                switch (optype) {
                    case "uploaduserlogo":
                    case "uploadcontent":
                    case "uploadflowpic":
                    case "uploadfloor":
                    case "uploadbadlogo":
                    case "uploadsitelogo":
                        if (strpicpath != "") {
                            
                            $("[DataField='spPic']").attr("src",strpicpath.split('|')[0]);
                            $("[DataField='hfPic']").val(strpicpath.split('|')[0]);
                            if ($("[DataField='UserLogo']").length > 0) {
                                $("[DataField='UserLogo']").val(strpicpath.split('|')[0]);
                            }

                            if ($("[DataField='hfId']").val() == "" || $("[DataField='hfId']").val() == "0") {
                                $("[DataField='hfId']").val(strpicpath.split('|')[1]);
                            }
                            if ($("[DataField='Id']").length > 0) {
                                $("[DataField='Id']").val(strpicpath.split('|')[1]);
                            }

                        }
                        break;
                   

                }
               YXQ.Common.Message("提示信息","上传完毕！");

            },
            onError: function (event, queueId, fileObj, errorObj) {
                alert(errorObj.info);
            }
        });
    }

}